home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
MANDLE_C
/
GRAPHICS.C
next >
Wrap
Text File
|
1990-05-06
|
1KB
|
74 lines
/*
graphics.c v1.0
Copyright 1990 Josh Pritikin
Tetrahedron Programming
All rights reserved.
2.14.90
*/
#define BLANK 0
extern WindowPtr window;
extern EventRecord event;
extern Boolean HALT;
static ColorSpec PriorColors[256];
int GETPIXEL(int x, int y)
{
RGBColor rgbc;
GetCPixel(x, y, &rgbc);
return Color2Index(&rgbc);
}
PUTPIXEL(int x, int y, int color)
{
RGBColor rgbc;
Index2Color((long)color, &rgbc);
SetCPixel(x, y, &rgbc);
GetNextEvent(everyEvent, &event);
if (Button()) HALT = true;
}
/* (x,y) is the start point and 'dir' the direction to travel in
'thecount' is the value to fill with
a line will be drawn until something is run into */
void FillLine(x,y,dir,thecount)
int x,y,dir,thecount;
{
int endx=x;
RGBColor rgbc;
while (GETPIXEL(endx,y) == BLANK)
endx -= dir;
Index2Color(thecount, &rgbc);
RGBForeColor(&rgbc);
MoveTo(x,y);
LineTo(endx,y);
}
InitScreen()
{
GDHandle gdh;
int bits_per, i;
gdh = GetMainDevice();
bits_per = (**(**gdh).gdPMap).pixelSize;
if ((**(**gdh).gdPMap).cmpSize != bits_per || bits_per != 8) OhShit();
for (i=0; i < 256; i++)
{
PriorColors[i].value = i;
Index2Color((long)i, &PriorColors[i].rgb);
}
}
RestoreScreen()
{
SetEntries(0, 255, PriorColors);
}